package cn.pugle.oj.leetcode;

import cn.pugle.oj.catalog.MathProblem;

/**
 * https://leetcode.com/problems/factorial-trailing-zeroes/
 *
 * @author tzp
 * @since 2020/11/18
 */
public class LC172_1 implements MathProblem {
    //关键在于几个5
    public int trailingZeroes(int n) {//n!
        int powFive = 5;
        int result = 0;
        while (n >= powFive) {
            result += n / powFive;
            powFive *= 5;
        }
        return result;
    }

    public static void main(String[] args) {
        System.out.println(new LC172_1().trailingZeroes(10));
        System.out.println(new LC172_1().trailingZeroes(20));
        System.out.println(new LC172_1().trailingZeroes(30));
        System.out.println(new LC172_1().trailingZeroes(332));//81
    }
}
